package webgraph;

import java.util.*;
import java.net.*;

public class graph {
	
	private LinkedList<gnode>  gNodes;
	
	public graph(){
		this.gNodes = new LinkedList<gnode>();
	}
	
	public int getGraphSize(){
		return this.gNodes.size();
	}
	
	public void addGnode(gnode n){
			this.gNodes.addLast(n);
	}
	
	public void removeGnode(gnode n){
		if(this.gNodes.contains(n))
			this.gNodes.remove(n);
	}
	
	public gnode getNodeAtPosition(int pos){
		if(pos < this.getGraphSize())
			return this.gNodes.get(pos);
		else
			return null;
	}
	
	public boolean searchVisitedURLs(String url) throws Exception{
		URL test = new URL(url);
		for(gnode n:this.gNodes){
			if(new URL(n.getURL()).equals(test) || n.getURL().equals(url))
				return true;
		}
		return false;
	}
	
	public void traverseBreadth(){
		int max = this.getGraphSize();
		int visited = 0;
		while(visited < max){
			visited++;
		}
	}
	
}
